﻿using System;

namespace WillsLLC.DbGen.Text.Inflection
{
    [Serializable]
    internal struct WordCategorization
    {
        public WordCategorization(String data)
            : this(data.Split(new Char[] { ' ' }, StringSplitOptions.None)) { }

        public WordCategorization(String[] data)
        {
            _word = data[0];
            _singularSuffix = data.Length > 1 ? data[1] : String.Empty;
            _pluralSuffixAnglicized = data.Length > 2 ? data[2] : String.Empty;
            _pluralSuffixClassical = data.Length > 3 ? data[3] : String.Empty;
        }

        private String _word;
        private String _singularSuffix;
        private String _pluralSuffixAnglicized;
        private String _pluralSuffixClassical;

        public Boolean IsCategoryMember(String word, String singularSuffix, String pluralSuffix, Boolean classicalMode)
        {
            return InflectionUtility.GetWordPattern(this._word).IsMatch(word)
                && singularSuffix.Equals(this._singularSuffix, StringComparison.InvariantCultureIgnoreCase)
                && (pluralSuffix.Equals(classicalMode ? this._pluralSuffixClassical : this._pluralSuffixAnglicized, StringComparison.InvariantCultureIgnoreCase));
        }
    }
}